package com.godofgamblers.hotelmanagementsystem.mapper;

import com.godofgamblers.hotelmanagementsystem.pojo.BookedCount;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/*

@author huanglang

@create_time 2019-10-17 09:46

Nothing is difficult but bugs

*/
@Repository
public interface OrderItemMapper {

    @Select("SELECT COUNT(*) AS booked,oi.room_type_id\n" +
            "FROM order_item oi,room_type rt\n" +
            "WHERE DATE_FORMAT(plan_stay_time,'%Y-%m-%d') <= #{day} AND #{day} < DATE_FORMAT(plan_leave_time,'%Y-%m-%d') AND (order_item_state=1 OR order_item_state=3) AND oi.room_type_id=rt.room_type_id\n" +
            "GROUP BY oi.room_type_id")
    public List<BookedCount> getBookedCounts(String day);
}
